let tabItem = document.querySelectorAll('.t-i');

tabItem.forEach(v => {
        v.onclick = function(){
          window.location.href="../list.html"
        }
});
// let search1 = document.querySelector('#s-table');
// search1.onclick= function(){
//   location.href="../list.html";
// }
$('#s-table').click(function(){
  location.href="../list.html";
})
let tabItem1 = document.querySelectorAll('.tt');

tabItem1.forEach(v => {
        v.onclick = function(){
          window.location.href="../index.html"
        }
});
  class searchList {
    constructor() {
      this.inputObj = document.getElementById('btn-search');
      this.inputObj.addEventListener("input", this.inputFn.bind(this));
      this.ulObj = document.querySelector('.search-res');
      
      this.inputObj.addEventListener('blur',this.disinputFn.bind(this));
      this.inputObj.addEventListener('click',this.clickFn.bind(this));
      this.time = "";
    }
    inputFn(eve) {
      clearTimeout(this.time);
      this.time = setTimeout(() => {
        let val = eve.target.value;
        if (!val) return (this.ulObj.style.display='none');
        this.bd(val);
      }, 100);
    //    if(!eve.target.value){
    //        this.ulObj.style.display='none';
    //    }
      
    }
    bd(kw) {
        let sc = document.createElement('script');
        sc.src = "https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + kw + "&json=1&p=3&sid=22084_1436_13548_21120_22036_22073&req=2&csor=0&cb=searchList.callback";
        document.head.appendChild(sc);
        sc.remove();
    }
    static callback(data){
        let {s} = data;
        
        if(!s.length)return;
        let ulObj = document.querySelector('.search-res');
        ulObj.style.display='block';
        let li ='';
        s.forEach(ele => {
            // let liObj = document.createElement('li');
            // liObj.innerHTML=ele;
            // li+=liObj;
            li+=`<li>${ele}</li>`;
            
        });
        ulObj.innerHTML=li;
    }
    disinputFn(){
       this.ulObj.style.display = 'none';
       
    }
    clickFn(eve){
        let val = eve.target.value;
        if (!val) return;
        this.bd(val);
    }
}

  new searchList();
  